package com.dzu.easy;

/**
 * @author ZhaoDong
 * @date 2022/9/27 10:34
 * @description 434. 字符串中的单词数
 */
public class Test434 {
    public static void main(String[] args) {
        System.out.println(countSegments(",,  , ,        a, eaefa"));
    }

    public static int countSegments(String s) {
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if ((i == 0 || s.charAt(i - 1) == ' ') && s.charAt(i) != ' ') {
                count++;
            }
        }

        return count;
    }
}
